home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 1.iso / ARGONET / PD / MATHS / RLAB / RLAB125.ZIP / !RLaB / help_ai / INTRO < prev    next >
Text File  |  1996-02-25  |  9KB  |  254 lines

  1. INTRO:
  2.  
  3.     Introduction to RLaB  "Our"-LaB.
  4.  
  5.     RLaB is a vector and matrix oriented, interactive, interpreted
  6.     programming LANGUAGE. Although RLaB started as an effort to
  7.     functionally replace MATLAB, the language and functions are
  8.     NOT MATLAB replicas. Although the language is similar to
  9.     MATLAB in some ways there are numerous differences (I hope for
  10.     the better). The help file MATLAB_DIFF briefly discusses the
  11.     primary differences between RLaB and MATLAB. If you are a
  12.     MATLAB expert please read the MATLAB_DIFF file ASAP.
  13.  
  14.     The RLaB Primer is also a good starting point for new users.
  15.     It is short, and provides many introductory examples.
  16.  
  17.     Using RLaB:
  18.  
  19.     To get this far you must already be running RLaB. At this
  20.     point you are using the command line interface. When RLaB
  21.     confronts you with the command line prompt (`>') it is ready
  22.     to accept any valid statement. As soon as a valid statement is
  23.     recognized, RLaB will execute it. For example
  24.  
  25.     > a = sqrt(2)
  26.      a =
  27.          1.41
  28.  
  29.     The right-hand-side (RHS) of the expression is evaluated, and
  30.     the result is assigned to `a' immediately.
  31.  
  32.     There are several data types. You do NOT need to declare
  33.     variable types, just use them (the variable(s)) in the proper
  34.     context. In the previous example `a' was a scalar. In the
  35.     following example `a' will be used as a matrix:
  36.  
  37.     > a = [1,2,3;4,5,6;7,8,9]
  38.      a =
  39.      matrix columns 1 thru 3
  40.                1           2           3
  41.                4           5           6
  42.                7           8           9
  43.  
  44.     The previous example created a matrix and stored it in the
  45.     variable (entity) `a'. The previous entity that `a'
  46.     represented (sqrt(2)) is destroyed.
  47.  
  48.     You can use most math operators like you would in C:
  49.  
  50.     a + b        Addition
  51.     a - b        Subtraction
  52.     a * b        Matrix Multiplication
  53.     a .* b        Matrix element-by-element multiply
  54.     a / b        Right Division
  55.     a ./ b        Element-by-element Right Division
  56.     a \ b        Left Division
  57.     a .\ b        Element-by-element Left Division
  58.     a^b        Power
  59.     a.^b        Element-by-element power
  60.     -a        Unary minus (negation)
  61.     +a        Unary plus 
  62.     a'        Matrix transpose (Hermitian transpose)
  63.     a.'        Matrix element-by-element transpose
  64.  
  65.     To see all of the available functions type `what()'. Try using
  66.     some:
  67.  
  68.     > what()
  69.     abs           error         log10         plot3         solve         
  70.     acos          eval          logspace      plprint       sort          
  71.     acosh         exist         lu            plptex        sprintf       
  72.     all           exp           lyap          plscol0       sqrt          
  73.     any           eye           max           plsfile       srand         
  74.     asin          factor        maxi          plstyle       std           
  75.     asinh         fft           mean          plwid         strsplt       
  76.     atan          filter        members       poly          strtod        
  77.     atan2         find          min           printf        subplot       
  78.     atanh         finite        mini          printmat      sum           
  79.     backsub       fix           mod           prod          svd           
  80.     balance       floor         nan           pstart        sylv          
  81.     cd            format        norm          ptitle        symm          
  82.     ceil          fprintf       num2str       putenv        system        
  83.     chol          fread         ode           pwin          tan           
  84.     class         fseek         ones          qr            tanh          
  85.     clear         fvscope       open          rand          tic           
  86.     clearall      getb          pause         rank          tmpnam        
  87.     close         getenv        plclose       rcond         toc           
  88.     compan        getline       plend         read          trace         
  89.     complement    hess          pl3d          readb         tril          
  90.     conj          hilb          plalt         readm         triu          
  91.     cos           ifft          plaspect      real          type          
  92.     cosh          imag          plaxis        redit         union         
  93.     cross         inf           plaz          replot        what          
  94.     cumprod       input         plcont        reshape       who           
  95.     cumsum        int           plegend       round         whos          
  96.     det           int2str       plerry        save          write         
  97.     diag          intersection  plfont        schord        writeb        
  98.     diary         inv           plgrid        schur         writem        
  99.     diff          isempty       plgrid3       set           xlabel        
  100.     disp          isinf         plhist        show          ylabel        
  101.     dlopen        isnan         plhistx       showpwin      zeros         
  102.     dot           issymm        plhold        sign          zlabel        
  103.     eig           length        plhold_off    sin                         
  104.     eign          linspace      plimits       sinh                        
  105.     eigs          load          plmesh        size                        
  106.     epsilon       log           plot          sizeof                      
  107.  
  108.      1st enter a matrix:
  109.  
  110.     > a = [1,2,3;4,5,6;7,8,9]
  111.      a =
  112.      matrix columns 1 thru 3
  113.                1           2           3
  114.                4           5           6
  115.                7           8           9
  116.     
  117.     Then transpose it:
  118.  
  119.     > b = a'
  120.      b =
  121.      matrix columns 1 thru 3
  122.                1           4           7
  123.                2           5           8
  124.                3           6           9
  125.  
  126.     Then perform matrix multiplication with the two matrices:
  127.  
  128.     > c = a * b
  129.      c =
  130.      matrix columns 1 thru 3
  131.               14          32          50
  132.               32          77         122
  133.               50         122         194
  134.  
  135.     Do an element - by - element multiply:
  136.  
  137.     > d = a .* b
  138.      d =
  139.      matrix columns 1 thru 3
  140.                1           8          21
  141.                8          25          48
  142.               21          48          81
  143.  
  144.     Zero out the element of a that is in the 3rd row, 3rd column.
  145.  
  146.     > a[3;3] = 0
  147.      a =
  148.      matrix columns 1 thru 3
  149.                1           2           3
  150.                4           5           6
  151.                7           8           0
  152.  
  153.     Use det() to compute the value of the determinant of [a].
  154.  
  155.     > det(a)
  156.               27
  157.  
  158.     Use another built-in function to estimate the reciprocal of
  159.     the condition number:
  160.  
  161.     > rcond(a)
  162.          0.01935
  163.     > 1/rcond(a)
  164.            51.67
  165.     
  166.     Use another built-in function to compute the matrix inverse:
  167.  
  168.     > inv(a)
  169.      matrix columns 1 thru 3
  170.           -1.778      0.8889     -0.1111
  171.            1.556     -0.7778      0.2222
  172.          -0.1111      0.2222     -0.1111
  173.  
  174.     Use yet another to compute the eigenvalues, and eigenvectors
  175.     of [a]:
  176.  
  177.     > eig( [1,2,3;4,5,6;7,8,9] )
  178.        val          vec          
  179.  
  180.     Notice that eig() appears to return two variables, val, and
  181.     vec. Actually eig() returns a LIST. A LIST is an entity that
  182.     contains other entities. Functions that need to return more
  183.     than one entity do so via a LIST. See `help LIST' if LISTs are
  184.     confusing you.
  185.  
  186.     The members of a list are accessed via a special syntax.
  187.  
  188.     list . lname
  189.  
  190.     will reference the member of the list with a name equal to
  191.     lname. For example:
  192.  
  193.     > eig([1,2,3;4,5,6;7,8,9]).val
  194.      val =
  195.      matrix columns 1 thru 3
  196.                    16.1 + 0i              -1.12 + 0i          -8.46e-16 + 0i
  197.  
  198.     will return the eigenvalues of the input. If you want to save
  199.     the entire list, then save it in a variable.
  200.  
  201.     > a = eig([1,2,3;4,5,6;7,8,9])
  202.        val          vec          
  203.  
  204.     Then you can access the members of the list:
  205.  
  206.     > a.val
  207.      val =
  208.      matrix columns 1 thru 3
  209.                    16.1 + 0i              -1.12 + 0i          -8.46e-16 + 0i
  210.     
  211.     > a.vec
  212.      vec =
  213.      matrix columns 1 thru 3
  214.                   0.232 + 0i              0.786 + 0i              0.408 + 0i
  215.                   0.525 + 0i             0.0868 + 0i             -0.816 + 0i
  216.                   0.819 + 0i             -0.612 + 0i              0.408 + 0i
  217.     
  218.     If you want to know what the names of the list members are you
  219.     can simply type the list variable at the prompt:
  220.  
  221.     > a
  222.        val          vec          
  223.  
  224.     Or, you can use the members function:
  225.  
  226.     > members(a)
  227.     val  vec  
  228.  
  229.     To see what variables are in the workspace, type `who()'
  230.  
  231.     > who()
  232.     a      c      pi                          
  233.     b      d      pinfo                       
  234.  
  235.     A variable can be removed from the workspace, and it's memory
  236.     freed, with the clear function:
  237.  
  238.     > clear(a, d)
  239.                2
  240.     > who()
  241.     b      c      pi     pinfo  
  242.  
  243.     Clear returns a number that signifies how many objects were
  244.     cleared from the workspace.
  245.  
  246.     At this point you should be starting to get an idea of some of
  247.     the things RLaB can do, even though we have not yet introduced
  248.     logical operators, conditional statements, looping statements,
  249.     and user-functions.
  250.  
  251.     Please skim through all the help files that are spelled with
  252.     capital letters. This will acquaint you with more features and
  253.     let you know where to go for help in the future.
  254.